package top.csjss.hospital.mapper;

import java.util.List;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Update;
import top.csjss.hospital.entity.Pharmacy;
import top.csjss.hospital.entity.PharmacyExample;

public interface PharmacyMapper {
    long countByExample(PharmacyExample example);

    int deleteByExample(PharmacyExample example);

    int deleteByPrimaryKey(Integer pharmacyId);

    int insert(Pharmacy record);

    int insertSelective(Pharmacy record);

    List<Pharmacy> selectByExample(PharmacyExample example);

    Pharmacy selectByPrimaryKey(Integer pharmacyId);

    int updateByExampleSelective(@Param("record") Pharmacy record, @Param("example") PharmacyExample example);

    int updateByExample(@Param("record") Pharmacy record, @Param("example") PharmacyExample example);

    int updateByPrimaryKeySelective(Pharmacy record);

    int updateByPrimaryKey(Pharmacy record);

    /**
     * 根据药品名查询药品信息
     * @param drugname
     * @return
     */
    List<Pharmacy> selectDrug(String drugname);

    /**
     * 添加數量
     * @param drugName
     * @param drugNum
     * @return
     */
    @Update("update pharmacy set drug_store_num = #{drugNum}+drug_store_num where pharmacy_name = #{drugName}")
    int updateNumByName(@Param(value = "drugName") String drugName, @Param(value = "drugNum") Integer drugNum);
}
